<?php $this->pageTitle=Yii::app()->name; ?>

<h1>Welcome to <i>Seamless Center</i></h1>
<div class="modal fade" id="myModal">
  <div class="modal-header">
    <a class="close" data-dismiss="modal">×</a>
    <h3>选择控件类型</h3>
  </div>
  <div class="modal-body">
  	<div class="row">
  		<div class="span3">
	   		<div class="control-group">
            <label class="control-label">控件类型</label>
            <div class="controls">
              <label class="radio">
                <input type="radio" name="optionsRadios" id="optionsRadios1" value="sudoku" checked="">
                Sudoku
              </label>
              <label class="radio">
                <input type="radio" name="optionsRadios" id="optionsRadios2" value="file_view">
                FileView
              </label>
            </div>
          </div>
	    </div>
	</div>
  <div class="modal-footer">
    <button class="btn btn-primary" id = "confirm_type">确认</button>
    <button class="btn btn-info" data-dismiss="modal">關閉</button>
  </div>
</div>
</div>

<div class="container fluid">
	<div class = "row fluid">	
		<img src="images/plus.png" id="plus" data-toggle="modal" href="#myModal" alt="plus">
	</div>
</div>

<script type="text/javascript">
	// GET VALUE OF RADIOS
	function GetRadioValue(RadioName){
	    var obj;    
	    obj=document.getElementsByName(RadioName);
	    if(obj!=null){
	        var i;
	        for(i=0;i<obj.length;i++){
	            if(obj[i].checked){
	                return obj[i].value;            
	            }
	        }
	    }
	    return null;
	}

	$(document).ready(function(){
 		  	  $('#confirm_type').click(function(){
 			  		var RValue;
 			  		RValue=GetRadioValue("optionsRadios");
 			  		if(RValue == "sudoku"){
 			  			$("#plus").before("<img src=\"images/sudoku.png\" class=\"sudoku\"alt=\"sudoku\">");
 			  		}
 			  		else if(RValue == "file_view"){
 			  			$("#plus").before("<img src=\"images/fileview.png\" class=\"file_view\" alt=\"fileview\">");
 			  		}
 			  		$('#myModal').modal('toggle');
 		  	  });
 		  	  $(".sudoku").live("click",function(){
				    window.location.href = "index.php?r=sudokuComp/displaySudoku";
			  });	  	  

 	});
</script>

